package com.lovo.homework7_8GameOfRockPaperScissors;

public class GameTest {
    public static void main(String[] args) {
        GameTest gameTest = new GameTest();
        gameTest.run();
    }

    private int[] point = {0};
    Computer computer = new Computer();
    Player player = new Player();

    public void run() {
        for (int i = 3; i > 0; i--) {
            computer.generate();
            int computerNumber = computer.getNumber();
            if (i==1){
                System.out.println("最后一次机会");
            }
            System.out.println(computer);
            player.generate();
            int playNumber = player.getNumber();
            switch (computerNumber) {
                case 0:
                    if (playNumber == 0) {
                        point[0] += 1;
                        System.out.println("平局，玩家积分加一，玩家总积分为："+point[0]+"，您还有"+(i-1)+"次机会");
                    }else if (playNumber==1){
                        point[0]+=3;
                        System.out.println("玩家获胜，玩家积分加三，玩家总积分为："+point[0]+"，您还有"+(i-1)+"次机会");
                    }else {
                        point[0]-=2;
                        System.out.println("电脑获胜，玩家积分减二，玩家总积分为："+point[0]+"，您还有"+(i-1)+"次机会");
                    }
                    break;
                case 1:
                    if (playNumber == 0) {
                        point[0] -= 2;
                        System.out.println("电脑获胜，玩家积分减二，玩家总积分为："+point[0]+"，您还有"+(i-1)+"次机会");
                    }else if (playNumber==1){
                        point[0]+=1;
                        System.out.println("平局，玩家积分加一，玩家总积分为："+point[0]+"，您还有"+(i-1)+"次机会");
                    }else {
                        point[0]+=3;
                        System.out.println("玩家获胜，玩家积分加三，玩家总积分为："+point[0]+"，您还有"+(i-1)+"次机会");
                    }
                    break;
                case 2:
                    if (playNumber == 0) {
                        point[0] += 3;
                        System.out.println("玩家获胜，玩家积分加三，玩家总积分为："+point[0]+"，您还有"+(i-1)+"次机会");
                    }else if (playNumber==1){
                        point[0]-=2;
                        System.out.println("电脑获胜，玩家积分减二，玩家总积分为："+point[0]+"，您还有"+(i-1)+"次机会");
                    }else {
                        point[0]+=1;
                        System.out.println("平局，玩家积分加一，玩家总积分为："+point[0]+"，您还有"+(i-1)+"次机会");
                    }
                    break;
            }
            if (i==1){
                System.out.println("游戏结束，您最终积分为"+point[0]);
            }
        }
    }
}
